import InteractiveBase from "../../../LevelCommon/InteractiveBase";
import FuseBox from "./FuseBox";
import { utils } from "../../../../utils/CommonUtil";

/** 保险丝开关*/
export default class FuseSwitch extends InteractiveBase {
    /** 保险丝箱*/
    private curFuseBox: FuseBox;
    public targetRotateAngle: Laya.Vector3;
    private mowner: Laya.Sprite3D;
    onStart() {
        this.mowner = this.owner as Laya.Sprite3D;
        this.curFuseBox = this.owner.parent.getComponent(FuseBox);
    }
    protected InteractiveLogic(): boolean {
        /** 如果保险丝都装上了 就可以开灯了*/
        if (this.curFuseBox.IsOnFuse()) {
            /** 调关卡脚本 进行操作开灯*/
            if (this.CallToLevel()) {
                utils.CommonUtils.DORotateTween(
                    this.mowner.transform,
                    this.mowner.transform.localRotationEuler
                    , this.targetRotateAngle,
                    500, null,true,false)
            }
        }
        return true;
    }
}